﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight.Messaging;

namespace Songhay.Composition.Extensions
{
    /// <summary>
    /// Extends <see cref="ICompositionMessaging"/>
    /// with MVVM Light messaging routines.
    /// </summary>
    public static partial class ICompositionMessagingExtensions
    {
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <typeparam name="TMessage">The type of the message.</typeparam>
        /// <param name="context">The context.</param>
        /// <param name="message">The message.</param>
        public static void SendMessage<TMessage>(this ICompositionMessaging context, TMessage message)
        {
            var data = new GenericMessage<TMessage>(message);
            Messenger.Default.Send(data);
        }
    }
}
